package hash;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 十八岁讨厌编程
 * @date 2025/6/27 21:14
 * @PROJECT_NAME leetcode
 * @description
 */

public class Solution349 {


    public int[] intersection(int[] nums1, int[] nums2) {
        int[] record1 = new int[1002];
        int[] record2 = new int[1002];
        for (int num : nums1) record1[num] += 1;
        for (int num : nums2) record2[num] += 1;
        List<Integer> resultList = new ArrayList<>();
        for (int i = 0; i < 1002; i++) if (record1[i] > 0 && record2[i] > 0) resultList.add(i);
        return resultList.stream().mapToInt(Integer::intValue).toArray();
    }


}
